#coding=utf-8
'''
Created on 2019年7月22日
'''
import json
class MyHttpResult(object):
    '''
    classdocs
    '''

    def __init__(self):
        '''
        Constructor
        '''
        self.code=0
        self.success=False
        self.msg="UnknowError"
        self.data=None
        
    def isSuccess(self):
        self.code=1
        self.success=True
        self.msg="Success"
    def setCode(self,code,msg=""):
        if isinstance(code, int):
            self.code=code
        if isinstance(msg, str):
            self.msg=msg
    def put(self,key,value=""):
        if isinstance(key, str) and len(key)>0:
            if self.data==None:
                self.data={}
            self.data[key]=value
    
    def getResult(self):
        return {
                "code":self.code
                ,"success":self.success
                ,"msg":self.msg
                ,"data":self.data
            }

if __name__ == "__main__":
    httpResult=MyHttpResult();
    httpResult.setCode(1)
    print json.dumps(httpResult.getResult(),indent=4)